/**
    当满足销售机会超期条件时，动态配置需通知联系人
 *  在销售机会超期（超期标准：立项到招标60天、招标到签合同2周）、成功、失败时。
 *  单项目：需通知销售部门区域主管，销售部门总监，子公司总经理；
 *  多项目和整体打包：增加通知到销售中心总监、销售管理部项目组。
 *  
 *  created by Harry 2016-12-20
 */
public with sharing class SetUserAfterTimeOutOfOppHandler implements Triggers.Handler{
    public void handle(){
        List<Opportunity> newList = (List<Opportunity>) Trigger.new;
        Map<Id,Opportunity> oldMap = (Map<Id,Opportunity>)Trigger.oldMap;
        
        for(Opportunity newopp: newList){
            Opportunity oldOpp = oldMap.get(newopp.Id);
            if(oldOpp.IsTimeout__c!=newOpp.IsTimeout__c && newOpp.IsTimeout__c == true){//超期状态发生改变
                if(newOpp.ProjectType__c== '单项目'){
                    newOpp.SalesDeptAreaManager__c=newOpp.Owner.SalesDeptAreaManager__c;
                    newOpp.DepartmentManager__c=newOpp.Owner.DepartmentManager__c;
                    newOpp.SubCompanyManager__c=newOpp.Owner.SubCompanyManager__c;
                }else if(newOpp.ProjectType__c== '多项目'||newOpp.ProjectType__c== '整体打包'){
                    newOpp.CenterExecutiveManager__c=newOpp.Owner.CenterExecutiveManager__c;
                    newOpp.SalesManageDeptTeam__c=newOpp.Owner.SalesManageDeptTeam__c;
                }
            }
        }
    }
}